<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./7.2/style.css">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <component :is="currentView"></component>
        <button @click="handleChangeView('A')">A</button>
        <button @click="handleChangeView('B')">B</button>
        <button @click="handleChangeView('C')">C</button>
        <button @click="handleChangeView('LIN')">C</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        let app = new Vue({
            el: '#app',
            components: {
                comA: {
                    template: '<div>组件A</div>'
                },
                comB:{
                    template: '<div>组件B</div>'
                },
                comC:{
                    template: '<div>组件C</div>'
                },
                comLIN:{
                    template: '<div>脑瓜子疼痛</div>'
                }
            },
            data(){
                return{
                    currentView: 'comA'
                }
            },
            methods:{
                handleChangeView: function(component){
                    this.currentView = 'com' + component;
                }
            }
        })
    </script>
</body>
</html>